package com.wkhyapp.lm.contract;

import com.wkhyapp.lm.base.BasePresenter;
import com.wkhyapp.lm.http.ApiCallback;
import com.wkhyapp.lm.http.net.BaseRequest;
import com.wkhyapp.lm.http.net.NoticeRequest;
import com.wkhyapp.lm.http.net.SuperResponse;
import com.wkhyapp.lm.http.vo.Category;
import com.wkhyapp.lm.http.vo.Notice;

/**
 * Created by Administrator on 2021-10-6.
 */

public class NoticePresenter  extends BasePresenter<NoticeView>{


    public NoticePresenter(NoticeView noticeView) {
        super(noticeView);
    }


    public void  getNotic(){
        NoticeRequest request = new NoticeRequest();
        request.setPageNo(1);
        request.setPageSize(10);
        addSubscription(apiStores.notices(request),new ApiCallback<SuperResponse<Notice>>() {
            @Override
            public void onSuccess(SuperResponse<Notice> response) {
                mvpView.setNotice(response.getItems());
            }
            @Override
            public void onFailure(String msg) {
//                mvpView.setfail("");
            }

            @Override
            public void onFinish() {
                mvpView.dismissLoad();
            }
        });

    }


    public void  getNoticMore(int pageNo){
        NoticeRequest request = new NoticeRequest();
        request.setPageNo(pageNo);
        request.setPageSize(10);
        addSubscription(apiStores.notices(request),new ApiCallback<SuperResponse<Notice>>() {
            @Override
            public void onSuccess(SuperResponse<Notice> response) {
                mvpView.setNoticeMore(response.getItems());
            }
            @Override
            public void onFailure(String msg) {
//                mvpView.setfail("");
            }

            @Override
            public void onFinish() {
                mvpView.dismissLoad();
            }
        });
    }



    public void  delAccount(int userID){
        BaseRequest request = new BaseRequest();
        request.setUserId(userID);
        addSubscription(apiStores.delMember(request),new ApiCallback<SuperResponse<String>>() {
            @Override
            public void onSuccess(SuperResponse<String> response) {
                mvpView.setNotice(null);
            }
            @Override
            public void onFailure(String msg) {
//                mvpView.setfail("");
            }

            @Override
            public void onFinish() {
                mvpView.dismissLoad();
            }
        });
    }
}
